import { _decorator, Component, Node } from "cc";
import BaseData from "./BaseData";
import global from "../config/global";
import GDef from "./GDef";
const { ccclass, property } = _decorator;

const CONFIGS = {
    cacheName: "playerInfo"
}
interface cacheData {
    isTouch: boolean, //玩家的触摸状态
    gameState: number,//游戏状态
    // playState: number,//玩家状态
}
//玩家数据管理
class playerMgr extends BaseData {//字段可以直接读,改动最好通过接口
    dictCache: cacheData
    constructor() {
        super(CONFIGS.cacheName);
    }
    init() {
        console.log("初始化玩家管理.........")
        this.dictCache = {
            isTouch: false,
            gameState: global.GAME_STATE.GAME_WAIT,
            // playState: global.PLAY_STATE.WAIT
        }
    }
    //设置触摸状态
    setIsTouch(boolean) {
        this.dictCache.isTouch = boolean;
    }

    getIsTouch() {
        return this.dictCache.isTouch;
    }

    /**
     * 设置游戏状态
     */
    setGameState(state: number): void {
        this.dictCache.gameState = state;
    }

    /**
     * 获取游戏状态
     */
    getGameState(): number {
        return this.dictCache.gameState;
    }

    // /**
    //  * 设置玩家状态
    //  */
    // setPlayState(state):void{
    //     this.dictCache.playState = state;
    // }

    // /**
    //  * 获取玩家状态
    //  */
    // getPlayState():number{
    //     return this.dictCache.playState;
    // }

    //
    // updateCache() {
    // }
}

export default playerMgr;